import { useCallback, useState } from 'react'

const useSetState = (obj: any) => {
  const [state, set] = useState(obj)
  const handleSet = useCallback((newVal) => {
    set((oVal: any) => (newVal instanceof Function ? newVal() : { ...oVal, ...newVal }))
  }, [])
  return [state, handleSet]
}
export default useSetState
